package com.poetry.jianjia.presenter;

import com.poetry.jianjia.net.Article;
import com.poetry.jianjia.view.IHomeView;

import poetry.jianjia.Call;
import poetry.jianjia.Callback;
import poetry.jianjia.Response;

/**
 * @author 裴云飞
 * @date 2021/1/26
 */

public class HomePresenter extends BasePresenter<IHomeView> {

    public HomePresenter(IHomeView view) {
        super(view);
    }

    @Override
    public void init() {

    }

    /**
     * 从服务端获取数据
     */
    public void getHomeArticle() {
        mWan.getHomeArticle(0).enqueue(new Callback<Article>() {
            @Override
            public void onResponse(Call<Article> call, Response<Article> response) {
                if (response.isSuccessful()) {
                    getView().setHomeArticle(response.body());
                }
            }

            @Override
            public void onFailure(Call<Article> call, Throwable t) {
                getView().onFailure(t);
            }
        });
    }
}
